package com.twu.biblioteca;

import java.util.ArrayList;

public class UserRegister {

    private static UserRegister userRegister;

    ArrayList<User> users = new ArrayList<User>();

    public void addUser(User user) {
        users.add(user);
    }

    public int userCount() {
        return users.size();
    }

    public User getUserByUsernameAndPassword(String username, String password) {
        for (User user : users) {
            if (user.credentialsMatch(username, password)) {
                return user;
            }
        }
        return null;
    }

    public static UserRegister getInstance() {
//        if(userRegister == null){
            userRegister = new UserRegister();
//        }
        userRegister.addUser(new User("111-1111", "pass", null, null));
        userRegister.addUser(new User("112-1111", "pass", null, null));
        return userRegister;
    }
}
